<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <script src="./js/earthsdk.js"></script>
    <!-- 自定义Css样式 -->
    <link rel="stylesheet" href="./css/example1.css">
    <title>Cesium地球初始化</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <div id="panel">
        <button onclick="createCamera()">创建摄像头</button>
    </div>
    <script>
        /** ---------------------------------地球创建------------------------------------**/
        // Vue中引入方式：import { ESObjectsManager } from 'earthsdk3';
        const { ESObjectsManager } = window['EarthSDK3']
        const { ESCesiumViewer } = window['EarthSDK3_Cesium']
        const { ESUeViewer } = window['EarthSDK3_UE']
        const objm = new ESObjectsManager(ESCesiumViewer, ESUeViewer);
        window.g_objm = objm;
        // 监听视口状态
        objm.viewerCreatedEvent.don((viewer) => {
            viewer.flyIn([
                110.58749553432271,
                20.268524281393816,
                192536.89974363067
            ], [
                335.78601015167027,
                -55.864586236154764,
                0.0003301719638204506
            ], 3)
        });
        // 创建Cesium视口
        const viewer = objm.createCesiumViewer(document.getElementById("app"));

        // 通过json创建一个影像图层
        const imageryLayer = objm.createSceneObjectFromJson({
            "id": "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
            "type": "ESImageryLayer",
            "maximumLevel": 16,
            "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
        });

        /** ---------------------------------------摄像头------------------------------------------**/
        const sceneObject = objm.createSceneObject('ESCameraVisibleRange')
        // 位置
        sceneObject.position = [110.31472888467145, 21.283075122275044, 0]

        // 姿态 
        sceneObject.rotation = [-34.89458482728109, 0.0011057411571762721, 0]

        // 远截面距离起点距离（米）
        sceneObject.far = 31118.14633685674

        // 视域夹角。属性值范围为0-180，不为0或180。
        sceneObject.fov = 100

        // 视域宽高比，纵向夹角计算方法：fov/aspectRatio。【属性值不可为0】
        sceneObject.aspectRatio = 1


        function createCamera() {

            const sceneObject = objm.createSceneObject('ESCameraVisibleRange')
            sceneObject.editing = true
        }
    </script>

    <!-- 切换UE和Cesium引擎的组件（Vue） -->
    <div id="root">
        <switch-engine :objm="objm"></switch-engine>
    </div>
    <!-- Vue文件 -->
    <script src="./js/vue.global.js"></script>
    <!-- 切换UE和Cesium的组件 -->
    <script src="./js/switchEngineCom.js"></script>
</body>

</html>